<?php

class Player_Piece
{
    private $_name = '';
    private $_player = null;
    private $_space = null; 

    public function __construct($name, $starting_space)
    {
        $this->setName($name);
        $this->setSpace($starting_space);
    }

    public function __toString()
    {
        return $this->getName();
    }

    public function setName($name)
    {
        $this->_name = $name;
    }

    public function getName()
    {
        return $this->_name;
    }

    public function setPlayer($player)
    {
        $this->_player = $player;
    }

    public function getPlayer()
    {
        return $this->_player;
    }

    public function setSpace($space)
    {
        $this->_space = $space;
    }

    public function getSpace()
    {
        return $this->_space;
    }

    public function move($spaces)
    {
        $this->setSpace($this->getSpace()->next());

        for ($i = 1; $i < $spaces; $i++) {
            $this->getSpace()->pass($this->getPlayer());
        }

        $this->getSpace()->land($this->getPlayer());
    }
}
